"use strict";
cc._RF.push(module, '95f86NK+rFG2YDQCu58XETZ', 'GbzUtils');
// scripts/GbzUtils.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.countGameLevelData = exports.getDiffArr = exports.takeValueFromArray = exports.getDistance = exports.getNumFromStr = exports.toXY = exports.timerFormat = exports.random = void 0;
function random(lower, upper) {
    return Math.floor(Math.random() * (upper - lower + 1)) + lower;
}
exports.random = random;
function timerFormat(seconds, dateFormat) {
    if (dateFormat === void 0) { dateFormat = 'h:i:s'; }
    seconds = Number(seconds);
    var obj = {};
    obj.h = Number.parseInt(String(seconds / 3600));
    obj.i = Number.parseInt(String((seconds - obj.h * 3600) / 60));
    obj.s = Number.parseInt(String(seconds - obj.h * 3600 - obj.i * 60));
    if (obj.h < 10)
        obj.h = '0' + obj.h;
    if (obj.i < 10)
        obj.i = '0' + obj.i;
    if (obj.s < 10)
        obj.s = '0' + obj.s;
    // 3.解析
    var rs = dateFormat.replace('h', obj.h).replace('i', obj.i).replace('s', obj.s);
    return rs;
}
exports.timerFormat = timerFormat;
function toXY(node1, node2, rpos) {
    if (rpos === void 0) { rpos = cc.v2(0, 0); }
    var wpos = node1.convertToWorldSpaceAR(rpos);
    var pos = node2.convertToNodeSpaceAR(wpos);
    return pos;
}
exports.toXY = toXY;
function getNumFromStr(str) {
    var arr = str.match(/\d+/g).map(Number);
    return arr[0];
}
exports.getNumFromStr = getNumFromStr;
function getDistance(start, end) {
    var pos = cc.v2(start.x - end.x, start.y - end.y);
    var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
    return dis;
}
exports.getDistance = getDistance;
function takeValueFromArray(arr, value, max) {
    if (max === void 0) { max = 3; }
    var result = [];
    var count = 0;
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] === value && count < max) {
            result.push(arr.splice(i, 1)[0]);
            count++;
            i--;
        }
    }
    return result;
}
exports.takeValueFromArray = takeValueFromArray;
function getDiffArr(arr1, arr2) {
    return arr1.filter(function (item) { return !arr2.includes(item); });
}
exports.getDiffArr = getDiffArr;
function countGameLevelData(arr) {
    var count = {};
    arr.forEach(function (num) {
        count[num] = (count[num] || 0) + 1;
    });
    return count;
}
exports.countGameLevelData = countGameLevelData;

cc._RF.pop();